package mammuthus.tool

import org.apache.velocity.VelocityContext
import java.io.StringWriter
import org.apache.velocity.app.Velocity

/**
 * 5/2/15 WilliamZhu(allwefantasy@gmail.com)
 */
object TemplateTool {
  def render(path: String, values: Map[String, AnyRef]) = {
    val context = new VelocityContext()
    values.map(f => context.put(f._1, f._2))
    val w = new StringWriter()
    Velocity.mergeTemplate(path, "utf-8", context, w)
    w.toString
  }
}
